<?php 
require_once __DIR__ . '/vendor/autoload.php';
if (strpos(strtolower(PHP_OS), 'win') === 0) {
    class_alias(\Windows\Worker::class,\Workerman\Worker::class);
    class_alias(\Windows\Events\Select::class,\Workerman\Events\Select::class);
}     
use Workerman\Worker;

// Create a Websocket server
$w1 = new Worker("tcp://127.0.0.1:9976"); 
$w1->count = 4;
$w1->onWorkerStart=function(){
    echo "A9976\n"; 
    $cc = new Workerman\Connection\AsyncTcpConnection('tcp://127.0.0.1:9977');
    $cc->connect();
    $cc->send('aa');
};
$w1->onMessage=function($conn,$data){
    echo $data;
};

$w2 = new Worker("tcp://127.0.0.1:9977"); 
$w2->count = 4;
$w2->onWorkerStart=function(){
    echo "B9977\n";
    $cc = new Workerman\Connection\AsyncTcpConnection('tcp://127.0.0.1:9976');
    $cc->connect();
    $cc->send('bb');
}; 
$w2->onMessage=function($conn,$data){
    echo $data;
};

$w3 = new Worker(); 
$w3->count = 4;
$w3->onWorkerStart=function(){ 
    echo "1111";
};  
// Run worker on windows
Worker::runAll();